package com.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.base.App;

/**
 * Created by ddd on 2018/2/3.
 */

public class SpUtil {
    private static final String SHARED_PREFERENCES_NAME = "app_sp";
    public static SharedPreferences getAppSp() {
        return App.getInstance().getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    }

    public static void setString(String key , String msg) {
        getAppSp().edit().putString(key, msg).commit();
    }

    public static String getString(String key) {
        return getAppSp().getString(key, "");
    }


    public static void setBoolean(String key , boolean msg) {
        getAppSp().edit().putBoolean(key, msg).commit();
    }

    public static boolean getBoolean(String key) {
        return getAppSp().getBoolean(key, false);
    }

    public static void setInt(String key , int msg) {
        getAppSp().edit().putInt(key, msg).commit();
    }

    public static int getInt(String key) {
        return getAppSp().getInt(key, 0);
    }
}
